package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.pojo.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {

    //新注册用户数  登陆次数
    @Select("select count(distinct user_id) from tb_log where log_time = #{today} and  type = #{type}")
    Integer findCountByLogTimeAndType(@Param("today") String today, @Param("type") String type);

    //活跃用户数
    @Select("select count(distinct user_id) from tb_log where log_time = #{today}")
    Integer findNumActive(@Param("today") String today);

    //次日留存用户数 昨天注册的，今天还在使用的
    @Select("select count(distinct user_id) from tb_log where log_time = #{today} and user_id in (" +
            "select distinct user_id from tb_log where log_time = #{yesterday} and type = 0102 )")
    Integer findNumRetention1d(@Param("today") String today, @Param("yesterday") String yesterday);



}
